package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.KeyAreaBean;
import com.sx.zongzhi.bean.KeyAreaSearchBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IKeyAreaView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取重点区域
 */
public class KeyAreaPest {

    private IKeyAreaView keyAreaView;

    public KeyAreaPest(IKeyAreaView keyAreaView) {
        this.keyAreaView=keyAreaView;
    }


    /**
     *
     * @param orgId 网格id
     * @param searchBean 查询的对象
     * @param page 页码
     * @param rows 页码显示条数
     */
    public void getKeyAreaList(String orgId, KeyAreaSearchBean searchBean, int page, int rows){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("orgId", orgId);
        if (searchBean!=null){
            map.put("importantArea.name",searchBean.getAreaName());
            map.put("importantArea.typeId", searchBean.getAreaType());
            map.put("importantArea.address", searchBean.getAreaAddress());
            map.put("importantArea.hasDanger", searchBean.isDanger());
            map.put("importantArea.leader", searchBean.getHeader());
            map.put("importantArea.telephone", searchBean.getTelephone());
            map.put("importantArea.mobileNumber",searchBean.getPhone());
        }
        map.put("page", page);
        map.put("rows", rows);
        new ApiManager().getKeyAreaList(map, new BaseCallBack<BaseResult<KeyAreaBean>>() {
            @Override
            public void onSuccess(BaseResult<KeyAreaBean> response) {
                keyAreaView.getKeyAreaList(response.getData());
            }
            @Override
            public void onFailures(String message) {
                keyAreaView.showError(message);
            }
        });
    }

}
